unit projects; 
(*
  srcstr
    projects.pas - Projects dialog
    (c)2006-2012 Matthew Hipkin <http://www.matthewhipkin.co.uk>
*)
{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  EditBtn, miscfunc;

type

  { TfrmProjects }

  TfrmProjects = class(TForm)
    btnOK: TButton;
    textProjectDir: TDirectoryEdit;
    lblDir: TLabel;
    lblInfo: TLabel;
    listProjects: TListBox;
    procedure btnOKClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure listProjectsClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  frmProjects: TfrmProjects;

implementation

uses main;

{$R *.lfm}

{ TfrmProjects }

procedure TfrmProjects.listProjectsClick(Sender: TObject);
var
  p: ^TskProject;
begin
  if listProjects.ItemIndex > -1 then
  begin
    if lblInfo.Visible = false then lblInfo.Visible := true;
    p := frmMain.projects[listProjects.ItemIndex];
    lblInfo.Caption := p^.description;
    textProjectDir.Directory := p^.localDir;
  end;
end;

procedure TfrmProjects.btnOKClick(Sender: TObject);
var
  p: ^TskProject;
begin
  if textProjectDir.Text = '' then
  begin
    showmessage('No project directory selected!');
    exit;
  end;
  if listProjects.ItemIndex > -1 then
  begin
    p := frmMain.projects[listProjects.ItemIndex];
    frmMain.currProject:= p^.id;
    ModalResult := mrOK;
  end
  else showmessage('No project selected!');
end;

procedure TfrmProjects.FormShow(Sender: TObject);
begin
end;

end.

